<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class AddFieldProductMinue extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        if (!Schema::hasColumn('product', 'minute')) {
            Schema::table('product', function (Blueprint $table) {
                $table->unsignedInteger('minute')->comment('过时时间');
            });
        }

        if (!Schema::hasColumn('orders', 'admin_id')) {
            Schema::table('orders', function (Blueprint $table) {
                $table->unsignedInteger('admin_id')->comment('用户ID');
            });
        }

        if (!Schema::hasColumn('app_users', 'start_time')) {
            Schema::table('app_users', function (Blueprint $table) {
                $table->string('start_time')->comment('开始日期');
            });
        }

        if (Schema::hasColumn('levels', 'input_1')) {
            Schema::table('levels', function (Blueprint $table) {
                $table->dropColumn('input_1');
            });
        }

        if (Schema::hasColumn('levels', 'input_2')) {
            Schema::table('levels', function (Blueprint $table) {
                $table->dropColumn('input_2');
            });
        }

        if (Schema::hasColumn('levels', 'input_3')) {
            Schema::table('levels', function (Blueprint $table) {
                $table->dropColumn('input_3');
            });
        }
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        if (Schema::hasColumn('product', 'minute')) {
            Schema::table('product', function (Blueprint $table) {
                $table->dropColumn('minute');
            });
        }

        if (Schema::hasColumn('orders', 'admin_id')) {
            Schema::table('orders', function (Blueprint $table) {
                $table->dropColumn('admin_id');
            });
        }

        if (Schema::hasColumn('app_users', 'start_time')) {
            Schema::table('app_users', function (Blueprint $table) {
                $table->dropColumn('start_time');
            });
        }
    }
}
